<div class="row">
    <form id="form-table" method="post" action="{:url('backup')}">
        <!-- 数据表格 -->
        <table class="table table-sorter">
            <!-- 表头 -->
            <thead>
            <tr>
            <tr>
                <th width="20">#</th>
                <th width="200">备份名称</th>
                <th width="80">卷数</th>
                <th width="80">压缩</th>
                <th width="80">数据大小</th>
                <th width="200">备份时间</th>
                <th>状态</th>
                <th width="120">操作</th>
            </tr>
            </tr>

            </thead>
            <!-- 列表 -->
            <tbody>
            {notempty name="data_list"} {volist name="data_list" id="data"}
            <tr>
                <td>{$i}</td>
                <td>{$data.time|date='Ymd-His'}</td>
                <td>{$data.part}</td>
                <td>{$data.compress}</td>
                <td>{$data.size|format_bytes}</td>
                <td>{$key}</td>
                <td>-</td>
                <td class="action"><a class="db-import" href="{:url('restore?time='.$data['time'])}">还原</a> <a
                        class="ajax-get confirm"
                        href="{:url('delete?time='.$data['time'])}">删除</a></td>
            </tr>
            {/volist} {else/}
            <tr>
                <td class="text-center" colspan="8">aOh! 暂时还没有内容!</td>
            </tr>
            {/notempty}
            </tbody>

        </table>
    </form>
</div>
<script>
    $(function () {

        $(".db-import").click(function () {
            var self = this, code = ".";
            $.get(self.href, success, "json");
            window.onbeforeunload = function () {
                return "正在还原数据库，请不要关闭！"
            }
            return false;

            function success(data) {
                if (data.code) {
                    if (data.data.gz) {
                        data.msg += code;
                        if (code.length === 5) {
                            code = ".";
                        } else {
                            code += ".";
                        }
                    }
                    $(self).parent().prev().text(data.msg);
                    if (data.data.part) {
                        $.get(self.href,
                            {"part": data.data.part, "start": data.data.start},
                            success,
                            "json"
                        );
                    } else {
                        window.onbeforeunload = function () {
                            return null;
                        }
                    }
                } else {
                    var msg = new $.zui.Messager(data.msg, {
                        placement: 'top',
                        type: 'danger'
                    }).show();
                    //layer.msg(data.msg, {icon: 5});
                }
            }
        });
    });

</script>
